feat: add client.Limits.MaxJOSECompactBytes for ID token/UserInfo size caps - #162
Merged
Conversation
…e caps The 16 KiB JOSE compact-serialization cap was a hardcoded package constant, but an ID token or UserInfo response scales with however many scopes/claims an issuer was asked to grant, so a fixed limit that fits one deployment can reject another's legitimate response. Make it caller-configurable, following the same pattern as Limits.MaxHTTPResponseBytes, and only for the two artifacts whose size actually varies this way — DPoP proofs, client assertions, request objects and JARM responses keep the package's fixed default since they're fixed-shape by construction. Also gives the JWE decrypt path (previously unbounded on its own) the same cap, and splits ErrorResponseTooLarge out of ErrorInvalidResponse so a caller can tell "too large" apart from "malformed" — internal/jose being unexported meant there was previously no way to distinguish the two from outside the module at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
client.Limits.MaxJOSECompactBytes, defaulted byRecommendedLimits(), following the same shape asLimits.MaxHTTPResponseBytes.jose.DefaultMaxCompactBytesdefault, since those are fixed-shape by construction and unaffected by this change.jwe.DecryptRequest.MaxCompactBytes), which previously had no early bound of its own.client.ErrorResponseTooLargecode so a caller can distinguish "response too large" from "malformed response" (previously both folded intoErrorInvalidResponsewith a misleading "malformed JWS" message) —internal/josebeing unexported meant there was previously no way to tell the two apart from outside the module at all.Test plan
go build ./...,go vet ./...,go test ./...all cleaninternal/jose.TestParseCompactMaxRespectsExplicitLimit,internal/jwe.TestDecryptRejectsOversizedCompact,client.TestFetchUserInfoRejectsSignedJWTOverConfiguredSizeLimitconformance/scripts/run-all.sh): AS baseline (57 modules, 4465 conditions, 0 failures), AS message-signing (71 modules, 5975 conditions, 0 failures), RP baseline (22/22 PASSED), RP message-signing (28/28 PASSED)https://claude.ai/code/session_013tGG2Ssuq5BDgCMbF8zYb8